#include "stdafx.h"

#include "PFItemNode.h"
#include "PFPortfilioNodes.h"

#include "PFData.h"

PFData::PFData(QObject * parent)
	: QObject(parent)
{
	m_pNodes = new PFPortfilioNodes(this);
}

PFData::~PFData()
{
	delete m_pNodes;
	m_pNodes = nullptr;
}

void PFData::SetStartRow(int row)
{
	m_iStart = row;
}

int PFData::GetStartRow() const
{
	return m_iStart;
}

int PFData::GetEndRow() const
{
	return m_iStart + RowCount(QModelIndex()) - 1;
}

PFItemNode * PFData::CrateNode()
{
	return new PFItemNode(this);
}

void PFData::SetEmptyCount(int count)
{
	m_iEmptys = count;
}

int PFData::GetEmptyCount() const
{
	return m_iEmptys;
}

void PFData::SetPreviousModel(PFData * model)
{
	m_pPreviousModel = model;
	if (m_pPreviousModel->GetNextModel() != this)
	{
		m_pPreviousModel->SetNextModel(this);
	}
}

PFData * PFData::GetPreviousModel() const
{
	return m_pPreviousModel;
}

void PFData::SetNextModel(PFData * model)
{
	m_pNextModel = model;
	if (m_pNextModel->GetPreviousModel() != this)
	{
		m_pNextModel->SetPreviousModel(this);
	}
}

PFData * PFData::GetNextModel() const
{
	return m_pNextModel;
}

PFModelType PFData::GetType() const
{
	return m_eType;
}

PFItemNode * PFData::Node(int row, int column, const QModelIndex & parent)
{
	return m_pNodes->Node(row, column, parent);
}
